<template>
	<view class="mainPage content" :style="{'padding-top': `${$store.state.safeArea.top || 0}px`, 'padding-bottom': `${$store.state.safeArea.bottom || 0}px`}">
		<public-head :title="title"></public-head>
		<view class="box">
			<u-notice-bar mode="horizontal" :list="list" class="tips"></u-notice-bar>
			<view class="title" style="">余额</view>
			<view class="title2" style="">{{lists.money}}</view>
		</view>
		<view class="box2" @click="torecord">
			<view class="record">提现记录</view>
		</view>
		<view class="box3">
			<view class="money">
				<view class="account" @click="addaccount">
					<view class="left">提现账户</view>
					<view class="right">
						<text>{{name}}</text>
						<text>{{account}}</text>
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
			</view>
			<view class="money">
				<u-field v-model="money" label="提现金额:" type="digit" :clearable="true" placeholder="请输入提现金额" placeholder-style=" ">
				</u-field>
			</view>
			<!--
			<view class="money">
				<view class="service">
					<text>提现服务费：{{service==null?'':service}}</text>
				</view>
			</view>
			-->
			<view class="service">
				<!-- <text>最小提现金额：{{lists.minMoney}}</text> -->
				<text>{{lists.remarks}}</text>
			</view>
			<view class="but">
				<button class="buts" v-if="account==''||account=='请选择提现账户'||money==''||money==0" @click="tixian">提现</button>
				<button class="active" v-else @click="toverification">提现</button>
			</view>
		</view>
	</view>
</template>
<script>
var that
import publicHead from "@/components/publicHead/publicHead.vue"
export default {
	components: {
		publicHead
	},
	data() {
		return {
			title: "提现",
			list: [],
			account: '请选择提现账户',
			mobile: '',
			money: '',
			lists: '',
			bank_id: '',
			name: '',
			service: '',//服务费
			rate: '',
			feiyong: ''
		}
	},
	onLoad(e) {
		that = this
		// that.withdrawal()
		// that.account=e.num
		// console.log('选中的银行卡信息为',e.num)
	},
	onShow() {
		var pages = getCurrentPages();
		var prevPage = pages[pages.length - 1];
		var num = prevPage.num;
		var id = prevPage.id;
		var name = prevPage.name;
		that.account = num
		that.bank_id = id
		that.name = name
		console.log('传过来的值', num, id, name)
		that.withdrawal()
	},
	methods: {
		addaccount() {
			uni.navigateTo({
				url: './account'
			})
		},
		tixian() {
			uni.showToast({
				title: '请先填写完整信息',
				icon: 'none',
				duration: 2000
			});
		},
		withdrawal() {
			that.$postAjax1('PetDoctor_Center_indinfo', {
			}, function (data) {
				that.lists = data.data.data
				that.list = data.data.data.tips
				// that.rate=data.data.data.rate

				// console.log('提现页面',that.rate)
			})
		},
		toverification() {
			// console.log(parseInt(that.money))
			// console.log(that.lists[0].money)
			// console.log(that.account)
			// if(that.lists.maxMoney<that.money){
			// 	uni.showToast({
			// 		title: '余额不足',
			// 		icon:'none',
			// 		duration: 2000
			// 	});
			// 	console.log('余额不足')
			// 	return
			// }
			if (that.lists.money < 50) {
				uni.showToast({
					title: '余额不得小于50元',
					icon: 'none',
					duration: 2000
				});
				return
			}
			console.log('即将跳转')
			uni.navigateTo({
				url: './verification?account=' + that.account + '&money=' + that.money + '&bank_id=' + that.bank_id
			})
		},
		torecord() {
			uni.navigateTo({
				url: './record'
			})
		},
		// inputs(){
		// 	that.service=parseFloat(that.money)*parseFloat(that.rate)
		// 	that.feiyong=parseFloat(that.service)+parseFloat(that.money)
		// }
	}
}
</script>
<style scoped lang="scss">
.content {
	width: 100vw;
	height: 100vh;
	background: #f6f6f6;
	.box {
		width: 750rpx;
		height: 336rpx;
		background: linear-gradient(219deg, #ff9331 0%, #fe7600 100%);
		.tips {
			opacity: 0.5;
		}
		.title {
			line-height: 100rpx;
			text-align: center;
			font-size: 38rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #ffffff;
		}
		.title2 {
			text-align: center;
			font-size: 40rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 600;
			color: #ffffff;
		}
	}
	.box2 {
		position: relative;
		margin-top: 30rpx;
		margin-bottom: 30rpx;
		height: 60rpx;
		.record {
			position: absolute;
			right: 20rpx;
			padding: 10rpx 20rpx;
			background: linear-gradient(223deg, #ff9331 0%, #fe7600 100%);
			border-radius: 4px;
			color: #ffffff;
		}
	}
	.box3 {
		.money {
			margin: 30rpx;
			border-radius: 12rpx;
			border: 1rpx solid rgba(0, 0, 0, 0.15);
			.account {
				padding: 20rpx;
				margin-top: 15rpx;
				.left {
					display: inline-block;
					width: 20%;
				}
				.right {
					display: inline-block;
					width: 80%;
					text-align: right;
					color: #8a8a8a;
				}
				text {
					color: #000000;
					margin-right: 50rpx;
				}
			}
		}
		.service {
			margin: 40rpx;
			color: #8a8a8a;
			font-size: 24rpx;
		}
	}
	.but {
		width: 100%;
		position: fixed;
		bottom: 130rpx;
		.buts {
			width: 90%;
			background: #8a8a8a;
			border-radius: 8rpx;
			font-weight: 400;
			color: #ffffff;
		}
		.active {
			width: 90%;
			background: linear-gradient(219deg, #ff9331 0%, #fe7600 100%);
			border-radius: 8rpx;
			font-weight: 400;
			color: #ffffff;
		}
	}
}
</style>
